package com.sd.activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

import com.mobclick.android.MobclickAgent;
import com.sd.activity.r.R;
import com.sd.view.ToastManager;

/**
 * 
 * 意见提交界面
 * 
 * @author Alex.Lu
 * 
 */
public class SubmitActivity extends BaseActivity implements OnClickListener {

	//返回按钮
	private ImageButton mReturn;
	//提交按钮
	private Button mSubmitBT;
	//建议编辑框
	private EditText mSubmitContentET;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_submit);
		
		mReturn = (ImageButton)findViewById(R.id.return_btn);
		mReturn.setOnClickListener(this);
		
		mSubmitBT = (Button)findViewById(R.id.submit_bt);
		mSubmitBT.setOnClickListener(this);
		
		mSubmitContentET = (EditText)findViewById(R.id.submit_content);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		int v_id = v.getId();
		switch (v_id) {
		case R.id.return_btn:
			finish();
			break;
		case R.id.submit_bt:
			String text = mSubmitContentET.getText().toString();
			
			if(text.trim().length() <=0){
				ToastManager.getInstance().showText(this, R.string.msg_submit_no);
			}else if(text.length() > 200){
				ToastManager.getInstance().showText(this, R.string.msg_submit_number_out);
			}else{
				MobclickAgent.onEvent(SubmitActivity.this, "submit_content", mSubmitContentET.getText().toString());
				mSubmitContentET.setText("");
				ToastManager.getInstance().showText(this, R.string.msg_submit_success);
			}
			break;
		default:
			break;
		}
	}


}